package org.data
{
	import flash.display.*;
	import flash.filesystem.*;
	
	import org.display.graphic.ShapeBase;
	import org.net.*;
	import org.utils.*;

	public class Global
	{
		public static var name:String="instance"
		public static var index:Number=0
			
		public static var configData:XML=null
			
		//用户名
		public static var username:String=""
			
		//场景对象
		public static var sceneSize:Number=10000
			
		//当前编辑对象，默认为场景
		public static var editObj:Sprite 
			
		//场景对象
		public static var scene:DisplayObject
			
		//工作空间
		public static var workspace:String=""
		
		//当前选择文件夹
		public static var selectPath:String=""
		
		//当前锁定文件夹
		public static var lockPath:String=""
			
		//编辑xml
		public static var xmlPath:String=""
			
		//容器
		public static var container:String=""
			
		//文档类或对象类
		public static var classType:String=""
			
		//文档类或对象类
		public static var jsflsPath:Array=[]
			
		public static var historyJsflsPath:Array=[]
			
			
		//当前正在操作事件流的shapeBase
		public static var nowShapeBase:ShapeBase
			
		//模板变量
		public static var eventSource:String=""
		public static var viewSource:String=""
		public static var viewjsflSource:String=""
		public static var modelSource:String=""
		public static var commandSource:String=""
		public static var commandControlSource:String=""
		public static var modelProxySource:String=""
		public static var viewProxySource:String=""
		public static var asynCommandSource:String=""
		public static var funCommandSource:String=""
			
		//AbcEventType.as变量
		public static var var_event:String="";
		
		//view.as模板变量
		public static var package_view:String=""
		public static var events_view:String=""	
		public static var import_view:String=""
		public static var var_view:String=""
		public static var onEnable_view:String=""
		public static var offEnable_view:String=""
		public static var function_view:String=""
		public static var mouseEvent_view:String=""	
		public static var init_view:String=""
			
		//model.as模板变量
		public static var package_model:String=""
		public static var var_model:String=""
		public static var function_model:String=""
			
		//view.jsfl模板变量
		public static var symbolLinkage_jsfl:String=""
		public static var items_jsfl:String=""
		public static var classType_jsfl:String=""
		public static var as3PackagePath_jsfl:String=""
			
		//command模板变量
		public static var package_command:String=""
		public static var import_commands:String=""
		public static var type_commands:String=""
		public static var class_commands:Array=[]
			
		//modelProxy模板变量
		public static var package_modelProxy:String=""
		public static var import_modelProxy:String=""
		public static var view_modelProxy:String=""
		public static var model_modelProxy:String=""
			
		//viewProxy模板变量
		public static var package_viewProxy:String=""
		public static var import_viewProxy:String=""
		public static var view_viewProxy:String=""
		public static var model_viewProxy:String=""	
			
			
			
		public function Global()
		{
		}
		
		public static function openDefault(){
            
			try{
				
			//打开main.fla
			var path:String=(Global.workspace+"/swf/org/display/main/main.fla").replace(/\\/gis,"/")
			var file:File = File.desktopDirectory.resolvePath(path);
			file.openWithDefaultApplication();
			
			//打开main.as3proj
			path=(Global.workspace+"/main.as3proj").replace(/\\/gis,"/")
			var file:File = File.desktopDirectory.resolvePath(path);
			file.openWithDefaultApplication();
			
			}catch(e:Error){
			
			trace(e)
				
			}

		}
		
		public static function reinit(){
		
			package_view=""
			events_view=""	
			import_view=""
			var_view=""
			onEnable_view=""
			offEnable_view=""
			function_view=""
			mouseEvent_view=""	
			init_view=""
			
			package_model=""
			var_model=""
			function_model=""
			
			symbolLinkage_jsfl=""
			items_jsfl=""
			classType_jsfl=""
				
			package_command=""
			import_commands=""
			class_commands=[]
			type_commands=""
				
			package_modelProxy=""
			import_modelProxy=""
			view_modelProxy=""
			model_modelProxy=""
				
			package_viewProxy=""
			import_viewProxy=""
			view_viewProxy=""
			model_viewProxy=""
		
		}
		
		public static function initLoad(){
		
			reinit()
			
			//加载模板文件========================================================
			var res:AbcResponder=new AbcResponder()
			res.onResult=function(e,path){
				switch(path.split("\/")[path.split("\/").length-1]){
					
					case "View.as":
						Global.viewSource=e
						break
					
						case "Model.as":
							Global.modelSource=e
							break
						
							case "View.jsfl":
								Global.viewjsflSource=e
								break
							
								case "Command.as":
									Global.commandSource=e
									break
								
								case "CommandControl.as":
									Global.commandControlSource=e
									break
								
								case "AbcEventType.as":
									Global.eventSource=e
									break
								
								case "ModelProxy.as":
									Global.modelProxySource=e
									break
								
								case "ViewProxy.as":
									Global.viewProxySource=e
									break
								
                                 case "AsynCommand.as":
									Global.asynCommandSource=e
									break
				                 case "FunCommand.as":
									Global.funCommandSource=e
									break
				}
				
				
			}
				
			var rootPath:String="AbcFrame/org/abcFrame/templete/"	
				
			new AbcHTTPServices(rootPath+"View.as",res)
			new AbcHTTPServices(rootPath+"Model.as",res)
			new AbcHTTPServices(rootPath+"View.jsfl",res)
			new AbcHTTPServices(rootPath+"Command.as",res)
			new AbcHTTPServices(rootPath+"ModelProxy.as",res)
			new AbcHTTPServices(rootPath+"ViewProxy.as",res)
			new AbcHTTPServices(rootPath+"AsynCommand.as",res)
			new AbcHTTPServices(rootPath+"FunCommand.as",res)
			
			new AbcHTTPServices(rootPath+"CommandControl.as",res)
			
			//new AbcHTTPServices("org/enmu/AbcEventType.as",res)
			

		}
		
		
		

	}
}